//
//  CNHelpViewController.m
//  BeeQuick_19
//
//  Created by clinging on 16/9/26.
//  Copyright © 2016年 CN Team. All rights reserved.
//

#import "CNHelpViewController.h"
#import "CNQuestionViewController.h"
#import "AppDelegate.h"
#import "CNHelpPlistController.h"

static NSString *reuseIdentifier = @"reuseIdentifier";


@interface CNHelpViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation CNHelpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self setupUI];
    // 点击拨号按钮直接拨号
    
    UIButton *btnPhone = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    btnPhone.frame = CGRectMake(280,10,30,30);
    
    [btnPhone setBackgroundColor:[UIColor redColor]];
    
    [btnPhone addTarget:self action:@selector(callAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btnPhone];
    

    
}


- (void)viewWillAppear:(BOOL)animated{
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    
//    self . tabBarController . tabBar . hidden = YES;
}

- (void)setupUI{
    
    self.navigationItem.title = @"客服帮助";
    
    UITableView *helpTabView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    
    [self.view addSubview:helpTabView];
    
    helpTabView.dataSource = self;
    helpTabView.delegate = self;
    [helpTabView registerClass:[UITableViewCell class] forCellReuseIdentifier:reuseIdentifier];
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier forIndexPath:indexPath];
    
    if (indexPath.section == 0 && indexPath.row == 0) {
        
        cell.textLabel.text = @"客服电话：400-8484-842";
        
    
    }
    
    if (indexPath.section == 0 && indexPath.row == 1) {
        
        cell.textLabel.text = @"常见问题";
        
    }
    
    return cell;
    
}
-(void)callAction{


    NSLog(@"打电话楼");
    
    NSString *number = @"";// 此处读入电话号码
    
    NSString *num = [[NSString alloc] initWithFormat:@"tel://%@",number]; //number为号码字符串 如果使用这个方法 结束电话之后会进入联系人列表
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //拨号

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
        if (indexPath.section == 0 && indexPath.row == 1){
        CNHelpPlistController *questionVc = [[CNHelpPlistController alloc]init];
        
        [self.navigationController pushViewController:questionVc animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
 NSLog(@"%ld   %ld",indexPath.section,(long)indexPath.row);
 
 if (indexPath.section == 0 && indexPath.row == 0) {
 
 NBAboutMeViewController *settingVc = [[NBAboutMeViewController alloc]init];
 
 [self.navigationController pushViewController:settingVc animated:YES];
 
 }
 
 
 }
 
 */

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
